<%@ page language="java" import= "java.util.*" import= "java.sql.*" import = "orm.*"  pageEncoding="utf-8" errorPage="errorPage.jsp"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base href = <%=basePath%> />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<%@ page import="util.*"%>
<%@ page import="org.w3c.dom.*" %>
<%@ page import="java.io.*"%>
<%@ page import="orm.*" %>
<%@ page import="java.util.Date" %>
<%@ page import="java.text.SimpleDateFormat" %>


<% Date dt=new Date();
   SimpleDateFormat matter1=new SimpleDateFormat("yyyy-MM-dd");
   
   ReadXml readnotice = new ReadXml();
   System.out.print(new File(application.getRealPath(request.getRequestURI())).getParentFile().getParentFile().getParent() +"\\xml\\notice.xml");
   Node newnotice = readnotice.getIndex(matter1.format(dt),
   new File(application.getRealPath(request.getRequestURI())).getParentFile().getParentFile().getParent() +"\\xml\\notice.xml");
%>


<title>通知</title>
<link href="css/iStyles.css" rel="stylesheet" type="text/css" />
<script language="javascript" type="text/javascript">
	function checkLogin() {
		if (document.login.username.value == "s")
		{
			document.login.action="../student/student.html";
		}
		if (document.login.username.value == "t")
		{
			document.login.action="../teacher/teacher.html";
		}
		if (document.login.username.value == "a")
		{
			document.login.action="../admi/admi.html";
		}
		document.login.submit();
	}
</script>
</head>

<body>
	<!-- CONTAINER START -->
<div id = "container">
<!-- HEADER START -->
        <div id = "top">
        	<div id = "navigation">
            	<html:link forward = "go_to_index" styleClass="link">&nbsp;&nbsp;&nbsp;&nbsp;首页</html:link>
            	<html:link forward = "go_to_notice" styleClass="link">&nbsp;&nbsp;&nbsp;&nbsp;通知</html:link>
            </div>
        </div>
        <!-- HEADER END -->
        
        <!-- LOGIN START -->
        <div id = "login">
        	<form method="post" action="login.do" name="login" onsubmit="return checkLogin(login);">
        	 <input   type="hidden"   name="org.apache.struts.taglib.html.TOKEN" 
        	value="<%=session.getAttribute("org.apache.struts.action.TOKEN")%>"   /> 
        		<div id = "userName">
            		<label>用户名：</label><input type="text" name="usernameL"
            		onkeyup="value=value.replace(/[\W]/g,'') "
            		onkeydown="if(event.keyCode==13) event.keyCode=9"/>
            	</div>
            	<div id = "password">
       		  	  <label>密&nbsp;&nbsp;&nbsp;码 ：</label><input type="password" name="pswL"/>
       	      </div>
       	        <div id = "type">
       	        <br/>
       	      </div>
           	    <div id = "rememberPWD">
           		  <input type="checkbox" name="rememberPWD" value="0" />记住密码&nbsp;
                	<a href="#" title="forget">忘记密码？</a>
   	 	      </div>
                <div id = "loginBt">
               	  <input type="submit" name="loginBt" value="登录" class="btn"/>
               	  <a href="register.do?method=init">注册</a>
              </div>
          </form>
        </div>
        <!-- LOGIN END -->
        
        <!-- CLOCK START -->
  <div id = "clock">
        	<iframe src="index/clock.html" height="407" width="296" frameborder="0" scrolling="no"
            		marginheight="0" marginwidth="0" id="clockFrame" name="clockFrame"></iframe>
</div>
        <!-- CLOCK END -->
        
        <!-- MAIN START -->
        <div id = "main">
        	<div id = "title">≡通知≡
            <hr />
            </div>
            <div id = "notice">
                <table>
                	<tr>
                		<td>
                		<p style="color:#000">
                		<%!String title = "",message = "No news is good news!",date = ""; %>
                		<%
                			if(newnotice != null){
                				NodeList list = newnotice.getChildNodes();
                				for(int i =0;i< list.getLength();i++){
                					if(list.item(i) instanceof Element){
                					System.out.println(list.item(i).getNodeName());
                						if(list.item(i).getNodeName().equals("title")){
                							title = list.item(i).getTextContent();
                						}
                						
                						if(list.item(i).getNodeName().equals("message")){
                							message = list.item(i).getTextContent();
                						}
                						
                						if(list.item(i).getNodeName().equals("date")){
                							date = list.item(i).getTextContent();
                						}
                					}
                				}
                		%>
                		<%=title%>
                		<%}%>
                		</p>
                		</td>
                	</tr>
                	<tr>
                		<td>
                			&nbsp;&nbsp;&nbsp;<p style="color:#000">内容</p>
                		</td>
                	</tr>
                	<tr>
                		<td>
                			<p style="color:#000">
                			<%=message%>
                			</p>
                		</td>
                	</tr>
                	<tr>
                        <td class="time">
                        	<p style="color:#000">
                			<%=date%>
                			</p>
                        </td>
                    </tr>
                </table>
            </div>
        </div>
   	<!-- MAIN END -->
        
   	<!-- FOOTER START -->
   	<div id = "footer">
  </div>
   	<!-- FOOTER END -->
        
  </div>
    <!-- CONTAINER END -->
    
</body>
</html>
